<?php
// For Pagination
function pagination($cur_page,$page,$per_page,$start,$previous_btn,$next_btn,$first_btn,$last_btn,$no_of_paginations,$finaldata,$count,$action,$valueName){
    $finaldata.="</tbody></table>";
        if ($cur_page >= 7) {
            $start_loop = $cur_page - 3;
            if ($no_of_paginations > $cur_page + 3)
                $end_loop = $cur_page + 3;
            else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6) {
                $start_loop = $no_of_paginations - 6;
                $end_loop = $no_of_paginations;
            } else {
                $end_loop = $no_of_paginations;
            }
        } else {
            $start_loop = 1;
            if ($no_of_paginations > 7)
                $end_loop = 7;
            else
                $end_loop = $no_of_paginations;
        }
        /* ----------------------------------------------------------------------------------------------------------- */
        if($count>$per_page){
            $finaldata .= "<div class='pagination'><ul>";
            
            // FOR ENABLING THE FIRST BUTTON
            if ($first_btn && $cur_page > 1) {
                $finaldata .= "<li p='1' class='active' data-tag-action='$action' data-value='$valueName'>First</li>";
            } else if ($first_btn) {
                $finaldata .= "<li p='1' class='inactive'>First</li>";
            }
            
            // FOR ENABLING THE PREVIOUS BUTTON
            if ($previous_btn && $cur_page > 1) {
                $pre = $cur_page - 1;
                $finaldata .= "<li p='$pre' class='active' data-tag-action='$action' data-value='$valueName'>Previous</li>";
            } else if ($previous_btn) {
                $finaldata .= "<li class='inactive'>Previous</li>";
            }
            for ($i = $start_loop; $i <= $end_loop; $i++) {
            
                if ($cur_page == $i)
                    $finaldata .= "<li p='$i' style='color:#ccc;background-color:#808080;' class='active' data-tag-action='$action' data-value='$valueName'>{$i}</li>";
                else
                    $finaldata .= "<li p='$i' class='active' data-tag-action='$action' data-value='$valueName'>{$i}</li>";
            }
            
            // TO ENABLE THE NEXT BUTTON
            if ($next_btn && $cur_page < $no_of_paginations) {
                $nex = $cur_page + 1;
                $finaldata .= "<li p='$nex' class='active' data-tag-action='$action' data-value='$valueName'>Next</li>";
            } else if ($next_btn) {
                $finaldata .= "<li class='inactive'>Next</li>";
            }
            
            // TO ENABLE THE END BUTTON
            if ($last_btn && $cur_page < $no_of_paginations) {
                $finaldata .= "<li p='$no_of_paginations' class='active' data-tag-action='$action' data-value='$valueName'>Last</li>";
            } else if ($last_btn) {
                $finaldata .= "<li p='$no_of_paginations' class='inactive'>Last</li>";
            }
            $finaldata = $finaldata . "</ul>" .  $total_string . "</div>";  // Content for pagination
        }
        echo $finaldata;
}
// Validation of the fields
function checkstrname($string){
        //echo "Here's your: ".$string."<br/>";
        $string;
        $checking_consecutives="";
        $letters=0;
        $spaces=0;
        $special=0;
        $errors=0;
        $magkasunod=0;
        $bilangmagkasunod=0;
        
        for($i=0;$i<strlen($string);$i++)
        {
                if(substr($string,$i-1,1)=="." && substr($string,$i,1)==" "){
                        if($spaces<=3){
                                $spaces++;
                        //	echo "spaces<br/>";
                        }else{
                                $errors++;
                        //	echo "lagpas na sa limitation spaces<br/>";
                        }
                }else{
                        if(  preg_match( '/^[a-zA-Z]/',substr($string,$i,1) )>0  ){ //validate from a to Z
                                $letters=1;
                                $magkasunod=0;
                        //	echo "letters<br/>";
                        }elseif( substr($string,$i,1)==" " ) { //if space
                                if($letters==0){
                                        $magkasunod++;
                                        if($spaces<=3){
                                                $spaces++;
                                        //	echo "spaces<br/>";
                                        }else{
                                                $errors++;
                                        //	echo "lagpas na sa limitation spaces<br/>";
                                        }
                                }else{
                                        $letters=0;
                                        if($spaces<=3){
                                                $spaces++;
                                        //	echo "spaces<br/>";
                                        }else{
                                                $errors++;
                                        //	echo "lagpas na sa limitation spaces<br/>";
                                        }
                                }
                                
                        }elseif( substr($string,$i,1)=="-" || substr($string,$i,1)=="."   ){ // if - and .
                                if($letters==0){
                                        $magkasunod++;
                                        $special++;
                                        $checking_consecutives=substr($string,$i);
                                //	echo "specials<br/>";
                                }else{
                                        $letters=0;
                                        $special++;
                                        $checking_consecutives=substr($string,$i);
                                //	echo "specials<br/>";
                                }
                        }else{  // if any unknown character
                                if($letters==0){
                                        $magkasunod++;
                                        $errors++;
                                //	echo "unknown: ".substr($string,$i,1)."<br/>";
                                }else{
                                        $letters=0;
                                        $errors++;
                                //	echo "unknown: ".substr($string,$i,1)."<br/>";
                                }
                        }
                }
                if($magkasunod>0){
                        $errors++;
                        $bilangmagkasunod++;
                //	echo "magkasunod to!<br/>";
                }
        }
        //echo "Count Mali: $errors<br/>Count Magkasunod: $bilangmagkasunod";
        if($errors>0){
                return 0;
        }else{
                return 1;
        }
}
//set Text Box
function setTextBox($id){
    $textbox = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='textbox' label-object='label$id' object-identifier='textBox$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <label class='labelObject' id='labelObject$id'><span id='label$id' class='labelElement'>Label:</span><span class='required' id='req_obj$id'></span></label>
        <input type='text' class='field$id input-xlarge textBox$id' fof='fof_textbox' ftu='ftu_textbox' require_check='0' showFieldObject_id='sfo_1' id='' disabled='disabled' readonly='readonly'>
    </span></a>";
    return $textbox;
}
//set Check Box
function setCheckbox($id){
    $checkbox= "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab' style=''>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='checkbox' label-object='label$id' object-identifier='checkbox$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <legend><small class='labelObject checkbox$id' id='labelObject$id' flayout_id='choicesDefCol' fof='fof_checkbox' ftu='ftu_checkbox' require_check='0' showFieldObject_id='sfo_1'><span id='label$id' class='labelElement'>Label:</span><span class='required' id='req_obj$id'></span></small></legend>
        <ul>
            <li class='choicesDefCol choices_li$id checkboxparentlist1$id'>
                <label id='checkbox' class='checkboxparent1$id'>
                <input type='checkbox' class='checkbox$id field$id objectsChoices$id checkbox1$id' id='checkbox1$id' child-id='checkChild1' style='margin-top:-3px;'><span class='checkboxlabel1$id' style='margin-left:10px;'>Sample 1</span>
                </label>
            </li>
            <li class='choicesDefCol choices_li$id checkboxparentlist2$id'>
                <label id='checkbox' class='checkboxparent2$id'>
                  <input type='checkbox' class='checkbox$id field$id objectsChoices$id checkbox2$id' id='checkbox2$id' child-id='checkChild2' style='margin-top:-3px;'><span class='checkboxlabel2$id' style='margin-left:10px;'>Sample 2</span>
                </label>
            </li>
            <li class='choicesDefCol choices_li$id checkboxparentlist3$id'>
                <label id='checkbox' class='checkboxparent3$id'>
                  <input type='checkbox' class='checkbox$id field$id objectsChoices$id checkbox3$id' id='checkbox3$id' child-id='checkChild3' style='margin-top:-3px;'><span class='checkboxlabel3$id' style='margin-left:10px;'>Sample 3</span>
                </label>
            </li>
        </ul>
    </span></a>";
    return $checkbox;
}
//set Dropdown
function setDropDown($id){
    $dropdown = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='dropdown' label-object='label$id' object-identifier='input-select-object$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <legend><small class='labelObject' id='labelObject$id'><span id='label$id' class='labelElement'>Label:</span><span class='required' id='req_obj$id'></span></small></legend>
            <select class='field$id input-select-object$id ' disabled='disabled' fof='fof_dropdown' ftu='ftu_dropdown' readonly='readonly' require_check='0' showFieldObject_id='sfo_1'>
                <option class='objectsChoices$id dropdown1$id dropdownObject$id dropdown$id' child-id='checkChild1' id='dropdown1$id'>Sample 1</option>
                <option class='objectsChoices$id dropdown2$id dropdownObject$id dropdown$id' child-id='checkChild2' id='dropdown2$id'>Sample 2</option>
                <option class='objectsChoices$id dropdown3$id dropdownObject$id dropdown$id' child-id='checkChild3' id='dropdown3$id'>Sample 3</option>
            </select>
    </span></a>";
    return $dropdown;
}
//set Radio
function setRadioButton($id){
    $radio = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab' style=''>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='radio' label-object='label$id' object-identifier='checkbox$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <legend><small class='labelObject checkbox$id' fof='fof_radio' ftu='ftu_radio' id='labelObject$id' flayout_id='choicesDefCol' require_check='0' showFieldObject_id='sfo_1'><span id='label$id' class='labelElement'>Label:</span><span class='required' id='req_obj$id'></span></small></legend>
        <ul>
            <li class='choicesDefCol choices_li$id radioparentlist1$id'>
                <label id='radio' class='checkboxparent1$id'>
                  <input type='radio' class='field$id radio$id objectsChoices$id checkbox1$id radioObject$id' child-id='checkChild1' id='radioObject1$id' style='margin-top:-3px;'><span class='checkboxlabel1$id' style='margin-left:10px;'>Sample 1</span>
                </label>
            </li>
            <li class='choicesDefCol choices_li$id radioparentlist2$id'>
                <label id='radio' class='checkboxparent2$id'>
                  <input type='radio' class='field$id radio$id objectsChoices$id checkbox2$id radioObject$id' child-id='checkChild2' id='radioObject2$id' style='margin-top:-3px;'><span class='checkboxlabel2$id' style='margin-left:10px;'>Sample 2</span>
                </label>
            </li>
            <li class='choicesDefCol choices_li$id radioparentlist3$id'>
                <label id='radio' class='checkboxparent3$id'>
                  <input type='radio' class='field$id radio$id objectsChoices$id checkbox3$id radioObject$id' child-id='checkChild3' id='radioObject3$id' style='margin-top:-3px;'><span class='checkboxlabel3$id' style='margin-left:10px;'>Sample 3</span>
                </label>
            </li>
        </ul>
    </span></a>";
    return $radio;
}
//set Textarea
function setTextArea($id){
    $textarea = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='textarea' label-object='label$id' object-identifier='textBox$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <label class='labelObject ' id='labelObject$id'><span id='label$id' class='labelElement'>Label:</span><span class='required' id='req_obj$id'></span></label>
        <textarea fof='fof_textarea' ftu='ftu_textarea' class='field$id input-xlarge textBox$id' disabled='disabled' require_check='0' showFieldObject_id='sfo_1' readonly='readonly'></textarea>
    </span></a>";
    return $textarea;
}
//set Select Many
function setselectMany($id){
    $selectMany = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='selectmany' label-object='label$id' object-identifier='input-select-object$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <legend><small class='labelObject' id='labelObject$id'><span id='label$id' class='labelElement'>Label:</span><span class='required' id='req_obj$id'></span></small></legend>
            <select multiple='multiple' fof='fof_selectmany' ftu='ftu_selectmany' class='field$id input-select-object$id ' require_check='0' showFieldObject_id='sfo_1'>
                <option class='objectsChoices$id selectMany1$id selectmany$id' child-id='checkChild1'>Sample 1</option>
                <option class='objectsChoices$id selectMany2$id selectmany$id' child-id='checkChild2'>Sample 2</option>
                <option class='objectsChoices$id selectMany3$id selectmany$id' child-id='checkChild3'>Sample 3</option>
            </select>
    </span></a>";
    return $selectMany;
}
//set Upload
function setUpload($id){
    $upload;/* = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span  id='spanObject$id' class='labelHover span11 setObject' master-id='$id' object-type='upload' label-object='labelObject$id' object-identifier='file$id'>
        <label class='labelObject' id='labelObject$id'>Label:</label>
        <input type='file' class='input-xlarge file$id' id='' style='z-index:100'>
    </span></a>";*/
    return "<script>alert('For Premium Account Only =)')</script>";
}
//set Date
function setDate($id){
    $date = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='datepicker' label-object='label$id' object-identifier='datePicker$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <label class='labelObject' id='labelObject$id'><span id='label$id' class='labelElement'>Date Picker:</span><span class='required' id='req_obj$id'></span></label>
        <input type='text' class='field$id input-xlarge datepicker datePicker$id' fof='fof_date' ftu='ftu_date' require_check='0' showFieldObject_id='sfo_1' disabled='disabled' readonly='readonly'>
    </span></a>";
    return $date;
}
//set Linebreak
function setLineBreak($id){
    $br = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='linebreak' label-object='label$id' object-identifier='linebreak$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <legend><small class='labelObject' id='labelObject$id'><span id='label$id'>Section Break</span><span class='required' id='req_obj$id'></span></small></legend>
            <p style='color: #555;' class='field$id linebreak$id' fof='fof_linebreak' ftu='ftu_linebreak' require_check='0' showFieldObject_id='sfo_1'>Description of page goes here</p>
    </span></a>";
    return $br;
}
//set pagebreak
function setPageBreak($id){
    $pr = "";
    return $pr;
}
//set fullname
function setFullName($id){
    $fn = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='fullname' label-object='label$id' object-identifier='fullname$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <label class='labelObject fullname$id' id='labelObject$id' fof='fof_fullname' ftu='ftu_fullname' require_check='0' showFieldObject_id='sfo_1' nf_id='nf_1'><span id='label$id' class='labelElement'>Full Name:</span><span class='required' id='req_obj$id'></span></label>
        <form class='form field$id'>
            <input type='text' class='input-xxlarge fn_fname$id' placeholder='Firstname' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xxlarge fn_mname$id' placeholder='Middlename' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xxlarge fn_lname$id' placeholder='Lastname' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge standard_fn$id fn_suffix$id' placeholder='Suffix' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge standard_fn$id fn_nname$id' placeholder='Nickname' disabled='disabled' readonly='readonly'>
        </form>
    </span></a>";
    return $fn;
}
//set datetime
function setDateTime($id){
    $dt = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='datetimepicker' label-object='label$id' object-identifier='datetimePicker$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <label class='labelObject' id='labelObject$id'><span id='label$id' class='labelElement'>Date Time:</span><span class='required' id='req_obj$id'></span></label>
        <input type='text' class='field$id input-xlarge datepicker datetimePicker$id' fof='fof_datetime' ftu='ftu_datetime' require_check='0' showFieldObject_id='sfo_1' id='' disabled='disabled' readonly='readonly'>
    </span></a>";
    return $dt;
}
//set website
function setWebsite($id){
    $wb = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='website' label-object='label$id' object-identifier='website$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <label class='labelObject' id='labelObject$id'><span id='label$id' class='labelElement'>Website:</span><span class='required' id='req_obj$id'></span></label>
        <form class='form-inline'>
        <input type='text' class='field$id input-xlarge website$id' require_check='0' fof='fof_website' ftu='ftu_website' showFieldObject_id='sfo_1' placeholder='Website' disabled='disabled' readonly='readonly'>
        </form>
    </span></a>";
    return $wb;
}
//set email
function setEmail($id){
    $email = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='email' label-object='label$id' object-identifier='email$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <label class='labelObject' id='labelObject$id'><span id='label$id' class='labelElement'>E-mail:</span><span class='required' id='req_obj$id'></span></label>
        <form class='form-inline'>
        <input type='text' class='field$id input-xlarge email$id' require_check='0' fof='fof_email' ftu='ftu_email' showFieldObject_id='sfo_1' placeholder='E-mail' disabled='disabled' readonly='readonly'>
        </form>
    </span></a>";
    return $email;
}
//set Time
function setTime($id){
    $time = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='timepicker' label-object='label$id' object-identifier='timepicker$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <label class='labelObject' id='labelObject$id'><span id='label$id' class='labelElement'>Time Picker:</span><span class='required' id='req_obj$id'></span></label>
        <form class='form-inline'>
        <input type='text' class='field$id input-xlarge timepicker$id' require_check='0' fof='fof_time' ftu='ftu_time' showFieldObject_id='sfo_1' disabled='disabled' readonly='readonly'>
        </form>
    </span></a>";
    return $time;
}
//set Address
function setAddress($id){
    $address = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='fulladdress' label-object='label$id' object-identifier='address$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
        <label class='labelObject address$id' id='labelObject$id' fof='fof_address' ftu='ftu_address' require_check='0' showFieldObject_id='sfo_1'><span id='label$id' class='labelElement'>Full Address:</span><span class='required' id='req_obj$id'></span></label>
        <form class='form field$id'>
            <input type='text' class='input-xxlarge' placeholder='Street Address' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xxlarge' placeholder='Address 2' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge' placeholder='City / Province' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge' placeholder='Postal / Zip Code' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge' placeholder='Region' disabled='disabled' readonly='readonly'>
            <select class='input-select-object' disabled='disabled' readonly='readonly'>
                <option>-Country-</option>
                <option>Sample 2</option>
                <option>Sample 3</option>
            </select>
        </form>
    </span></a>";
    return $address;
}
function setrichText($id){
    $richtext = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$id' data-toggle='tab'>
    <span id='spanObject$id' class='labelHover span12 setObject borderDashed' master-id='$id' object-type='richtext' label-object='label$id' object-identifier='richtext$id'>
    <span style='cursor:pointer;color:red;' class='close' id='close$id'>x</span>
    <label class='labelObject richtext$id' id='labelObject$id' fof='fof_richtext' ftu='ftu_richtext' require_check='0' showFieldObject_id='sfo_1'><span id='label$id' class='labelElement'>Rich Text:</span><span class='required' id='req_obj$id'></span></label>
    <textarea id='textarea$id' cols='50' rows='15'></textarea>
    </span></a>"
    ?>
    <script>
    $(document).ready(function(){
        $("#textarea<?php echo $id; ?>").htmlarea();
    })
    </script>
    <?php
    return $richtext;
}
/******FOR EXTRACTING**************/
function form_extract($form_title,$description,$label_placement){
    $result = "<span id='head' class='span12' style='text-align:$label_placement'>
                    <h4 class=''>$form_title</h4>
                    <p style='color: #555;' class=''>$description</p>
                </span>";
    return $result;
}
function fof_textbox($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $size_class = fieldsize($size);
    $result = "<span class='span12'>
                    <label>$label";
    $result.=getRequired($choices_id);
    $result.="</label>";
    $result.="<input type='text' class='fof $size_class' rel='text' label='$label' id='fof_textbox_$choices_id' option_req='$options' sft='$sft' object-type='textbox'>
                </span></a>";
    return $result;
}
function fof_checkbox($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<span class='span12 fof' rel='choice' id='fof_checkbox_$choices_id' option_req='$options'>
                <legend>
                    <small>$label";
    $result.=getRequired($choices_id);
    $result.=  "</small></legend>
                <ul>";
    $result.= getChoices($choices_id,$f_type,$f_layout);
    $result.= "</ul></span>";
    return $result;
}
function fof_dropdown($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result.="<span class='span12 fof' rel='drop' id='fof_dropdown_$choices_id' option_req='$options'>
                <legend><small>$label";
    $result.=getRequired($choices_id);          
    $result.="</small></legend>
                <select>";
    $result.= getChoices($choices_id,$f_type,$f_layout);
    $result.="</select>
            </span>";
    return $result;
}
function fof_radio($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<span class='span12 fof' rel='choice' id='fof_radio_$choices_id' option_req='$options'>
                <legend>
                    <small>$label";
    $result.=getRequired($choices_id);
    $result.="</small></legend>
                <ul>";
    $result.= getChoices($choices_id,$f_type,$f_layout);
    $result.= "</ul></span>";
    return $result;
}
function fof_textarea($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $size_class = fieldsize($size);
    $result = "<span class='span12 ' >
                    <label>$label";
    $result.=getRequired($choices_id);
    $result.="      </label>
                    <textarea class='$size_class fof' rel='text' id='fof_textarea_$choices_id' label='$label' option_req='$options' object-type='textarea'></textarea>
                </span></a>";
    return $result;
}
function fof_selectmany($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result.="<span class='span12'>
                <legend><small>$label";
    $result.=getRequired($choices_id);
    $result.="</small></legend>
                <select multiple='multiple' class='fof' rel='drop' id='fof_selectmany_$choices_id' label='$label' option_req='$options'>";
    $result.= getChoices($choices_id,$f_type,$f_layout);
    $result.="</select>
            </span>";
    return $result;
}
function fof_date($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $size_class = fieldsize($size);
    $result = "<span class='span12 '>
                    <label>$label";
    $result.=getRequired($choices_id);
    $result.="</label>
                    <input type='text' class='datepicker $size_class fof' rel='text' id='fof_date_$choices_id' label='$label' option_req='$options' object-type='date'>
                </span>";
    ?>
    <script>$(".datepicker").datepicker();</script>
    <?php
    return $result;
}
function fof_linebreak($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<span class='span12'>
                    <legend><small class=''>$label</small></legend>
                        <p style='color: #555;' >$lb_desc</p>
                </span>";
    return $result;
}
function fof_fullname($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<span class='span12'>
                    <label>$label".getRequired($choices_id)."</label>";
     $result.="<form class='form fof' id='fof_fullname_$choices_id' rel='special' type='fullname' label='$label' option_req='$options'>
                <input type='text' class='input-xxlarge fof_fullname_$choices_id' id='fof_fullname".$choices_id."_firstname' placeholder='Firstname'>
                <input type='text' class='input-xxlarge fof_fullname_$choices_id' id='fof_fullname".$choices_id."_middlename' placeholder='Middlename'>
                <input type='text' class='input-xxlarge fof_fullname_$choices_id' id='fof_fullname".$choices_id."_lastname' placeholder='Lastname'>";
    if($name_format=="nf_1"){
        $result.=" <input type='text' class='input-xlarge fof_fullname_$choices_id' id='fof_fullname".$choices_id."_suffix' placeholder='Suffix'>
                        <input type='text' class='input-xlarge fof_fullname_$choices_id' id='fof_fullname".$choices_id."_nickname' placeholder='Nickname'>";
    }
        $result.="</form>
                    </span>";
    return $result;
}
function fof_datetime($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    /**  ?  **/
    $size_class = fieldsize($size);
    $result = "<span class='span12'>
                    <label>$label";
    $result.=getRequired($choices_id);
    $result.="       </label>
                    <input type='text' class='datetime $size_class fof' rel='text' id='fof_datetime_$choices_id' label='$label' option_req='$options' object-type='datetime'  sft='$sft' >
                </span></a>";
    ?>
    <script>
        $('.datetime').datetimepicker();
    </script>
    <?php
    return $result;
}
function fof_website($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    //textbox with validation of website
    $size_class = fieldsize($size);
    $result = "<span class='span12'>
                    <label>$label";
    $result.=getRequired($choices_id);
    $result.="      </label>
                    <input type='text' class='$size_class fof' rel='text' id='fof_website_$choices_id' label='$label' option_req='$options' object-type='website' sft='$sft' >
                </span></a>";
    return $result;
}
function fof_email($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    //textbox with validation of email
    $size_class = fieldsize($size);
    $result = "<span class='span12'>
                    <label>$label";
    $result.=getRequired($choices_id);
    $result.="      </label>
                    <input type='text' class='$size_class fof' rel='text' id='fof_email_$choices_id' label='$label' option_req='$options' object-type='email' sft='$sft' >
                </span></a>";
    return $result;
}
function fof_time($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    /**  ?  **/
    $size_class = fieldsize($size);
    $result = "<span class='span12'>
                    <label>$label";
    $result.=getRequired($choices_id);
    $result.="      </label>
                    <input type='text' class='timepicker $size_class fof' rel='text' id='fof_time_$choices_id' label='$label' option_req='$options' object-type='time' sft='$sft' >
                </span></a>";
    ?>
    <script>
        $('.timepicker').timepicker();;
    </script>
    <?php        
    return $result;
}
function fof_address($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<span class='span12'>
        <label class=''>$label";
    $result.=getRequired($choices_id);
    $result.="</label>
        <form class='form fof' rel='special' type='address' id='fof_address_$choices_id' option_req='$options' label='$label'>
            <input type='text' class='input-xxlarge fof_address_$choices_id' id='fof_address".$choices_id."_street' placeholder='Street Address'>
            <input type='text' class='input-xxlarge fof_address_$choices_id' id='fof_address".$choices_id."_address2' placeholder='Address 2'>
            <input type='text' class='input-xlarge fof_address_$choices_id' id='fof_address".$choices_id."_province' placeholder='City / Province'>
            <input type='text' class='input-xlarge fof_address_$choices_id' id='fof_address".$choices_id."_postal' placeholder='Postal / Zip Code'>
            <input type='text' class='input-xlarge fof_address_$choices_id' id='fof_address".$choices_id."_region' placeholder='Region'>
            <select class='input-select-object fof_address_$choices_id' select='true' id='fof_address".$choices_id."_country' >
                <option>-Country-</option>
            </select>
        </form>
    </span>";
    return $result;
}
function fof_richtext($label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<span class='span12'>
    <label>$label";
    $result.=getRequired($choices_id);
    $result.="</label>
    <textarea class='textarea' cols='50' rows='15'></textarea>
    </span>"
    ?>
    <script>$(document).ready(function(){
        $(".textarea").htmlarea();
    })</script>
    <?php
    return $result;
}
/******EXTRACT IN UPDATE FORM*************/
function ftu_form($formTitle,$formdescription,$label_placement){
    $result = "<a href='#tab3' data-toggle='tab' class='formtitleHolder'>
                <span id='head' class='span12 setObjectForm borderDashed' style='text-align:$label_placement'>
                    <h4 style='cursor: pointer;' class='formTitleText' align='$label_placement'>$formTitle</h4>
                    <p style='color: #555;' class='formDescText'>".stripslashes($formdescription)."</p>
                </span>
            </a>";
    return $result;
}


function ftu_textbox($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $size_class = fieldsize($size);
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
                <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='textbox' label-object='label$uniqueID' object-identifier='textBox$uniqueID'>
                <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                    <label class='labelObject' id='labelObject$uniqueID'><span id='label$uniqueID'>$label</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>";
    $result.="<input type='text' class='field$uniqueID $size_class textBox$uniqueID' fof='fof_textbox' ftu='ftu_textbox' require_check='$options' showFieldObject_id='$sft' disabled='disabled' readonly='readonly'>
                </span></a>";
    return $result;
}
function ftu_checkbox($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab' style=''>
    <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='checkbox' label-object='label$uniqueID' object-identifier='checkbox$uniqueID'>
    <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
        <legend><small class='labelObject checkbox$uniqueID' id='labelObject$uniqueID' flayout_id='choicesDefCol' fof='fof_checkbox' ftu='ftu_checkbox' require_check='$options' showFieldObject_id='sfo_1'><span id='label$uniqueID'>$label</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</small></legend>
        <ul>";
    $result.= getEditChoices($choices_id,$f_type,$f_layout,$uniqueID);
    $result.= "</ul></span></a>";
    return $result;
}
function ftu_dropdown($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result.="<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
            <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='dropdown' label-object='label$uniqueID' object-identifier='input-select-object$uniqueID'>
            <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                <legend><small class='labelObject' id='labelObject$uniqueID'><span id='label$uniqueID'>$label";
    $result.="</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</small></legend>
            <select class='field$uniqueID input-select-object$uniqueID' disabled='disabled' fof='fof_dropdown' ftu='ftu_dropdown' readonly='readonly' require_check='$options' showFieldObject_id='$sft'>";
    $result.= getEditChoices($choices_id,$f_type,$f_layout,$uniqueID);
    $result.="</select>
            </span></a>";
    return $result;
}
function ftu_radio($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab' style=''>
                <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='radio' label-object='label$uniqueID' object-identifier='checkbox$uniqueID'>
                <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                <legend>
                    <small class='labelObject checkbox$uniqueID' fof='fof_radio' ftu='ftu_radio' id='labelObject$uniqueID' flayout_id='choicesDefCol' require_check='$options' showFieldObject_id='$sft'><span id='label$uniqueID'>$label";
    $result.="</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</small></legend>
              <ul>";
    $result.= getEditChoices($choices_id,$f_type,$f_layout,$uniqueID);
    $result.= "</ul></span><a>";
    return $result;
}
function ftu_textarea($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $size_class = fieldsize($size);
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
                <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='textarea' label-object='label$uniqueID' object-identifier='textBox$uniqueID'>
                <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                    <label class='labelObject ' id='labelObject$uniqueID'><span id='label$uniqueID'>$label";
    $result.="     </span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>
                    <textarea fof='fof_textarea' ftu='ftu_textarea' class='field$uniqueID $size_class textBox$uniqueID' disabled='disabled' require_check='$options' showFieldObject_id='$sft' readonly='readonly'></textarea>
                </span></a>";
    return $result;
}
function ftu_selectmany($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $size_class = fieldsize($size);
    $result.="<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
            <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='selectmany' label-object='label$uniqueID' object-identifier='input-select-object$uniqueID'>
            <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                <legend><small class='labelObject' id='labelObject$uniqueID'><span id='label$uniqueID'>$label";
    $result.="</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</small></legend>
                <select multiple='multiple' fof='fof_selectmany' ftu='ftu_selectmany' class='field$uniqueID $size_class input-select-object$uniqueID ' require_check='$options' showFieldObject_id='$sft'>";
    $result.= getEditChoices($choices_id,$f_type,$f_layout,$uniqueID);
    $result.="</select>
            </span></a>";
    return $result;
}
function ftu_date($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $size_class = fieldsize($size);
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
            <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='datepicker' label-object='label$uniqueID' object-identifier='datePicker$uniqueID'>
            <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                    <label class='labelObject' id='labelObject$uniqueID'><span id='label$uniqueID'>$label";
    $result.="</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>
                    <input type='text' class='$size_class field$uniqueID datepicker datePicker$uniqueID' fof='fof_date' ftu='ftu_date' require_check='$options' showFieldObject_id='sfo_1' disabled='disabled' readonly='readonly'>
                </span></a>";
    return $result;
}
function ftu_linebreak($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
                <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='linebreak' label-object='label$uniqueID' object-identifier='linebreak$uniqueID'>
                <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                    <legend><small class='labelObject' id='labelObject$uniqueID'><span id='label$uniqueID'>$label</span><span class='required' id='req_obj$uniqueID'></span></small></legend>
                        <p style='color: #555;' class='field$uniqueID linebreak$uniqueID' fof='fof_linebreak' ftu='ftu_linebreak' require_check='$options' showFieldObject_id='sfo_1'>$lb_desc</p>
                </span></a>";
    return $result;
}
function ftu_fullname($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
   $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
            <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='fullname' label-object='label$uniqueID' object-identifier='fullname$uniqueID'>
            <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                    <label class='labelObject fullname$uniqueID' id='labelObject$uniqueID' fof='fof_fullname' ftu='ftu_fullname' require_check='$options' showFieldObject_id='sfo_1' nf_id='$name_format'><span id='label$uniqueID'>$label
                </span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>
            <form class='form'>";
    if($name_format=="nf_1"){
        //full
        $result.="<form class='form'>
            <input type='text' class='input-xxlarge fn_fname$uniqueID' placeholder='Firstname' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xxlarge fn_mname$uniqueID' placeholder='Middlename' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xxlarge fn_lname$uniqueID' placeholder='Lastname' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge standard_fn$uniqueID fn_suffix$uniqueID' placeholder='Suffix' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge standard_fn$uniqueID fn_nname$uniqueID' placeholder='Nickname' disabled='disabled' readonly='readonly'>";
    }elseif($name_format=="nf_2"){
        $result.="<form class='form'>
            <input type='text' class='input-xxlarge fn_fname$uniqueID' placeholder='Firstname' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xxlarge fn_mname$uniqueID' placeholder='Middlename' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xxlarge fn_lname$uniqueID' placeholder='Lastname' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge standard_fn$uniqueID fn_suffix$uniqueID' placeholder='Suffix' style='display:none' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge standard_fn$uniqueID fn_nname$uniqueID' placeholder='Nickname' style='display:none' disabled='disabled' readonly='readonly'>";
    }
    $result.="</form>
            </span></a>";
    return $result;
}
function ftu_datetime($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $size_class = fieldsize($size);
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
            <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='datetimepicker' label-object='label$uniqueID' object-identifier='datetimePicker$uniqueID'>
            <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                    <label class='labelObject' id='labelObject$uniqueID'><span id='label$uniqueID'>$label";
    $result.="</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>
                    <input type='text' option_req='$options' class='$size_class field$uniqueID input-xlarge datepicker datetimePicker$uniqueID' fof='fof_datetime' ftu='ftu_datetime' require_check='$options' showFieldObject_id='sfo_1' id='' disabled='disabled' readonly='readonly'>
                </span></a>";
    return $result;
}
function ftu_website($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    //textbox with validation of website
    $size_class = fieldsize($size);
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
            <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='website' label-object='label$uniqueID' object-identifier='website$uniqueID'>
            <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                    <label class='labelObject' id='labelObject$uniqueID'><span id='label$uniqueID'>$label";
    $result.="</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>
                    <form class='form-inline'>
                    <input type='text' class='$size_class field$uniqueID website$uniqueID' option_req='$options' require_check='$options' fof='fof_website' ftu='ftu_website' showFieldObject_id='sfo_1' placeholder='Website' disabled='disabled' readonly='readonly'>
                    </form>
                </span></a>";
    return $result;
}
function ftu_email($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    //textbox with validation of email
    $size_class = fieldsize($size);
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
            <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='email' label-object='label$uniqueID' object-identifier='email$uniqueID'>
            <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                    <label class='labelObject' id='labelObject$uniqueID'><span id='label$uniqueID'>$label";
    $result.="</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>
                    <form class='form-inline'>
                    <input type='text' class='$size_class field$uniqueID email$uniqueID' option_req='$options' require_check='$options' fof='fof_email' ftu='ftu_email' showFieldObject_id='sfo_1' placeholder='E-mail' disabled='disabled' readonly='readonly'>
                    </form>
                </span></a>";
    return $result;
}
function ftu_time($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $size_class = fieldsize($size);
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
            <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='timepicker' label-object='label$uniqueID' object-identifier='timepicker$uniqueID'>
            <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
                    <label class='labelObject' id='labelObject$uniqueID'><span id='label$uniqueID'>$label";
    $result.="      </span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>
                    <form class='form-inline'>
                    <input type='text' class='$size_class field$uniqueID input-xlarge timepicker$uniqueID' option_req='$options' require_check='$options' fof='fof_time' ftu='ftu_time' showFieldObject_id='sfo_1' disabled='disabled' readonly='readonly'>
                    </form>
                </span></a>";      
    return $result;
}
function ftu_address($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
    <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='fulladdress' label-object='label$uniqueID' object-identifier='address$uniqueID'>
    <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
        <label class='labelObject address$uniqueID' id='labelObject$uniqueID' fof='fof_address' ftu='ftu_address' require_check='$options' showFieldObject_id='sfo_1'><span id='label$uniqueID'>$label</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>
        <form class='form field$uniqueID'>
            <input type='text' class='input-xxlarge' placeholder='Street Address' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xxlarge' placeholder='Address 2' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge' placeholder='City / Province' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge' placeholder='Postal / Zip Code' disabled='disabled' readonly='readonly'>
            <input type='text' class='input-xlarge' placeholder='Region' disabled='disabled' readonly='readonly'>
            <select class='input-select-object' disabled='disabled' readonly='readonly'>
                <option>-Country-</option>
                <option>Sample 2</option>
                <option>Sample 3</option>
            </select>
        </form>
    </span></a>";
    return $result;
}
function ftu_richtext($uniqueID,$label,$size,$options,$sft,$f_layout,$name_format,$lb_desc,$f_type,$choices_id){
    $result = "<a href='#tab2' class='span11 formobjectHolder' id='spanParent$uniqueID' data-toggle='tab'>
    <span id='spanObject$uniqueID' class='labelHover span12 setObject borderDashed' master-id='$uniqueID' object-type='richtext' label-object='label$uniqueID' object-identifier='richtext$uniqueID'>
    <span style='cursor:pointer;color:red;' class='close' id='close$uniqueID'>x</span>
    <label class='labelObject richtext$uniqueID' id='labelObject$uniqueID' fof='fof_richtext' ftu='ftu_richtext' require_check='$options' showFieldObject_id='sfo_1'><span id='label$uniqueID'>$label</span><span class='required' id='req_obj$uniqueID'></span>".getRequired($choices_id)."</label>
    <textarea id='textarea$uniqueID' cols='50' rows='15'></textarea>
    </span></a>"
    ?>
    <script>$(document).ready(function(){
        $("#<?php echo "textarea$uniqueID"; ?>").htmlarea();
    })</script>
    <?php
    return $result;
}

/******EXTRA FUNCTIONS*************/
function fieldsize($size){
    $result = "";
    if($size=="fz_default"){
        $result = "input-medium";
    }elseif($size=="fz_small"){
        $result = "input-medium";
    }elseif($size=="fz_medium"){
        $result = "input-large";
    }elseif($size=="fz_large"){
        $result = "input-xlarge";
    }elseif($size=="fz_long"){
        $result = "input-xxlarge";
    }
    return $result;
}
function getEditChoices($id,$f_type,$f_layout,$uniqueID){
    $db = new Database;
    $count = 1;
    $query_options = $db->query("SELECT * from tbchoices WHERE field_id='$id'","array");
    $result = "";
    $check = "";
    foreach($query_options as $row){
        //for attr check
        if($f_type=="checkbox" || $f_type=="radio"){
            if($row['checked']=="1"){
                $check = "checked='checked'";
            }else{
                $check = "";
            } 
        }else{
            if($row['checked']=="1"){
                $check = "selected='selected'";
            }else{
                $check = "";
            } 
        }
        //validate if what type of field
        if($f_type=="checkbox"){
            $result.="<li class='$f_layout choices_li$uniqueID checkboxparentlist$count$uniqueID'>
                        <label id='checkbox' class='checkboxparent$count$uniqueID'>
                        <input type='checkbox' $check class='field$uniqueID objectsChoices$uniqueID checkbox$count$uniqueID checkbox$uniqueID' id='checkbox$count$uniqueID' child-id='checkChild$count' style='margin-top:-3px;'><span class='checkboxlabel$count$uniqueID' style='margin-left:10px;'>".$row['choice_label']."</span>
                        </label>
                    </li>";
        }elseif($f_type=="radio"){
            $result.="<li class='$f_layout choices_li$uniqueID radioparentlist$count$uniqueID'>
                        <label id='radio' class='checkboxparent$count$uniqueID'>
                        <input type='radio' class='field$uniqueID objectsChoices$uniqueID checkbox$count$uniqueID radioObject$uniqueID radio$uniqueID' child-id='checkChild$count' id='radioObject$count$uniqueID' style='margin-top:-3px;'>
                        <span class='checkboxlabel$count$uniqueID' $check style='margin-left:10px;'>".$row['choice_label']."</span>
                    </label></li>";
        }elseif($f_type=="dropdown"){
            $result.="<option $check class='objectsChoices$uniqueID dropdown$count$uniqueID dropdownObject$uniqueID $f_type$uniqueID' child-id='checkChild$count' id='dropdown$count$uniqueID'>".$row['choice_label']."</option>";
        }elseif($f_type=="selectmany"){
            $result.="<option $check class='objectsChoices$uniqueID selectMany$count$uniqueID selectmany$uniqueID' child-id='checkChild$count'>".$row['choice_label']."</option>";
        }
        $count++;
    }
    return $result;
}
function getChoices($id,$f_type,$f_layout){
    $db = new Database;
    $query_options = $db->query("SELECT * from tbchoices WHERE field_id='$id'","array");
    $result = "";
    $check = "";
    $count = 1;
    foreach($query_options as $row){
        //for attr check
        if($f_type=="checkbox" || $f_type=="radio"){
            if($row['checked']=="1"){
                $check = "checked='checked'";
            }else{
                $check = "";
            }  
        }else{
            if($row['checked']=="1"){
                $check = "selected='selected'";
            } else{
                $check = "";
            }
        }
        //validate if what type of field
        if($f_type=="checkbox"){
            $result.="<li class='$f_layout'><label id='checkbox'>
                        <input type='checkbox' class='fof_checkbox_$id' label='".$row['choice_label']."' value='".$row['choice_label']."' style='margin-top:-3px;' $check>
                        <span style='margin-left:10px;'>".$row['choice_label']."</span>
                    </label></li>";
        }elseif($f_type=="radio"){
            $result.="<li class='$f_layout'><label id='checkbox'>
                        <input type='radio' ".checkedRadio($count)." class='fof_radio_$id' label='".$row['choice_label']."' value='".$row['choice_label']."' name='radio".$id."' style='margin-top:-3px;' $check>
                        <span style='margin-left:10px;'>".$row['choice_label']."</span>
                    </label></li>";
        }elseif($f_type=="dropdown"){
            $result.="<option class='fof_dropdown_$id' label='".$row['choice_label']."' $check>".$row['choice_label']."</option>";
        }elseif($f_type=="selectmany"){
            $result.="<option class='fof_selectmany_$id' label='".$row['choice_label']."' $check>".$row['choice_label']."</option>";
        }
        $count++;
    }
    return $result;
}
function checkedRadio($count){
    if($count==1){
        return "checked='checked'";
    }
}
function getRequired($id){
    $db = new Database;
    $query_options = $db->query("SELECT * from tbfield_output WHERE id='$id'","row");
    $return = "";
    if($query_options['options']==1){
        $return = "<span class='required'>*</span>";
    }
    return $return;
}
//other functions
function status($status){
    $ret = "";
    if($status==1){
        $ret = "Active";
    }elseif($status==0){
        $ret = "Inactive";
    }
    return $ret;
}
//other functions
function deletedStatus($status){
    $ret = "";
    if($status==1){
        $ret = "Active User";
    }elseif($status==0){
        $ret = "For Request";
    }
    return $ret;
}
function reverseStatus($status){
    $ret = "";
    if($status==0){
        $ret = "Activate";
    }elseif($status==1){
        $ret = "Deactivate";
    }
    return $ret;
}
function statCol($status,$id,$class,$href=null){
    if($status==0){
        return "<td style='text-align: center'><a class='editAdmin edit_".$class."' id='".$id."' rel='".$class."' style='cursor: pointer'>Edit</a></td>
        <td style='text-align: center'><a class='activateAdmin activate_".$class."' id='".$id."' rel='".$class."' style='cursor: pointer'>".reverseStatus($status)."</a></td>
        <td style='text-align: center'><a class='deleteAdmin delete_".$class."' id='".$id."' rel='".$class."' style='cursor: pointer'>Delete</a></td>";
    }else{
        return "<td style='text-align: center'><a class='editAdmin edit_".$class."' id='".$id."' rel='".$class."' style='cursor: pointer'>Edit</a></td>
        <td style='text-align: center'><a class='deactivateAdmin deact_".$class."' id='".$id."' rel='".$class."' style='cursor: pointer'>Deactivate</a></td>
        <td style='text-align: center'><a class='deleteAdmin delete_".$class."' id='".$id."' rel='".$class."' style='cursor: pointer'>Delete</a></td>";
    }
}

function activeDiagram($status){
    if($status==1){
        return "activeDiagram";
    }
}

function setName($firstname,$middlename,$lastname){
    if($middlename==""){
        return $firstname." ".$lastname;
    }else{
        return $firstname." ".$middlename." ".$lastname;
    }
}

function setSelected($old,$new){
    if($old==$new){
        return "selected='selected'";
    }
}
function setChecked($old,$new){
    if($old==$new){
        return "checked='checked'";
    }
}
function setArrow($left,$top,$setClass,$axis,$setid,$master_id,$child_id,$linetype){
    if($axis=="pp" || $axis=="np"){
       return '<div class="line '.$setClass.' newLines" axis="'.$axis.'" id="'.$setid.'" line-type="'.$linetype.'" style="position:absolute;left:'.($left).';top:'.$top.';background-color:black" master_id="'.$master_id.'" child_id="'.$child_id.'">
                    <div style="position:absolute;left:0px;top:0px;margin-top:-5px;width:13px;height:1px;clip:rect(0,11px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:1px;top:0px;margin-top:-4px;width:11px;height:1px;clip:rect(0,9px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:2px;top:0px;margin-top:-3px;width:9px;height:1px;clip:rect(0,7px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:3px;top:0px;margin-top:-2px;width:7px;height:1px;clip:rect(0,5px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:4px;top:0px;margin-top:-1px;width:5px;height:1px;clip:rect(0,3px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:5px;top:0px;margin-top:0px;width:3px;height:1px;clip:rect(0,1px,1px,0);background: inherit;overflow:hidden;"></div>
                  </div>';
    }else if($axis=="pn" || $axis == "nn"){
        return '<div class="line '.$setClass.' newLines" axis="'.$axis.'" id="'.$setid.'" line-type="'.$linetype.'" style="position:absolute;left:'.($left+36).'px;top:'.$top.'px;background-color:black" master_id="'.$master_id.'" child_id="'.$child_id.'">
                    <div style="position:absolute;left:0px;top:0px;margin-top:62px;width:13px;height:1px;clip:rect(0,11px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:1px;top:0px;margin-top:61px;width:11px;height:1px;clip:rect(0,9px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:2px;top:0px;margin-top:60px;width:9px;height:1px;clip:rect(0,7px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:3px;top:0px;margin-top:59px;width:7px;height:1px;clip:rect(0,5px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:4px;top:0px;margin-top:58px;width:5px;height:1px;clip:rect(0,3px,1px,0);background: inherit;overflow:hidden;"></div>
                    <div style="position:absolute;left:5px;top:0px;margin-top:57px;width:3px;height:1px;clip:rect(0,1px,1px,0);background: inherit;overflow:hidden;"></div>
                  </div>';    
    }else{
        return 1;
    }
}
function roleType($roleType){
    if($roleType==1){
        return "Head";
    }elseif($roleType==2){
        return "Assistant Head";
    }else if($roleType==3){
        return "Member";
    }else{
        return "";
    }
}
function roleApprover($user_groupType,$user_group){
    if($user_groupType==1){
        return "rp.approver= 'Head_".$user_group."' or rp.approver= 'Assistant Head_".$user_group."'";
    }else if($user_groupType==2){
        return "rp.approver= 'Assistant Head_".$user_group."'";
    }else if($user_groupType==3){
        return "rp.approver= 'Member_".$user_group."'";
    }
}
function getUserWholeName($id){
    $db = new Database;
    $getName = $db->query("SELECT * FROM tbuser where id='$id'","row");
    return setName($getName['firstname'],$getName['middlename'],$getName['lastname']);
}
function setApproverTitle($approver){
    $approverArray = explode("_",$approver);
    if($approver=="0"){
        return "<b>User Cancelled the request</b>";
    }else if($approver=="1"){
        return "<b>User Has been Deactivated</b>";
    }else{
        if(count($approverArray)==1){
            return $approver;
        }else{
            return $approverArray[0]." of ".$approverArray[1]." Department";
        }
    }
}
function requestStatus($requestStatus){
    if($requestStatus==2){
        return "<span style='color:red'>Request Rejected!</span>";
    }else if($requestStatus==1){
        return "<span style='color:green'>Request Approved!</span>";
    }else if($requestStatus==3){
        return "<span style='color:orange'>Request Canceled!</span>";
    }else if($requestStatus==0){
        return "<span style='color:blue'>Request Pending..</span>";
    }
}

//Email Verification
function VerifyMailAddress($emailAddress) 
{
   $Syntax='/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/';
   if(preg_match($Syntax,$emailAddress))
      return true;
   else
     return false;

}
function setColon($data){
    $pos = strpos($data, ":");
    if($pos==true){
        return $data;
    }else if($pos==false){
        return $data.":";
    }
}
function setFormValues($dataValues){
    $returnVals = "";
    $comma = "";
    $getDataValues = explode("|",$dataValues);
    if(count($getDataValues)==1){
        $returnVals.=$dataValues;
    }else{
        for($a=0;$a<count($getDataValues)-1;$a++){
            if($getDataValues[$a+1]!=""){
                $comma = ", ";
            }
            $returnVals.=$getDataValues[$a].$comma;
        }    
    }
    return $returnVals;
}